package cn.linkai.star.graph.core.controller;

import cn.linkai.star.graph.core.dto.common.Result;
import cn.linkai.star.graph.core.dto.request.UserLoginReqDTO;
import cn.linkai.star.graph.core.dto.respone.UserLoginResDTO;
import cn.linkai.star.graph.core.service.UserService;
import lombok.RequiredArgsConstructor;
import org.apache.coyote.BadRequestException;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/1.0/user")
public class UserController {

    private final UserService userService;
    /**
     * 登录
     * @param userLoginReqDTO
     * @return
     */
    @PostMapping("/login")
    public Result<UserLoginResDTO> login(@RequestBody UserLoginReqDTO userLoginReqDTO) throws BadRequestException {
        UserLoginResDTO userLoginResDTO = userService.loginByPassword(userLoginReqDTO);
        return Result.ok (userLoginResDTO);
    }

}
